﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>全局自定义模板</title>
</head>
<body>
<!--css配置-->
<style>
    /* .unconfirmed,.signSheet,.exportQRcode{
        display: none;
    }
    .print {
        display: none;
    } */
</style>
<!--是否加载全局模板 请填写正确的load-template 格式：http://www.xxx.com/-->
<section id="rootTemplate" load-template=""></section>
<!--配置API地址 可以覆盖root配置 api-url格式：http://www.xxx.com/-->
<section id="controller" api-url=""></section>
<!--RootToolbar配置-->
<section id="toolbar">
    <action text="打印预览"  code="printcustom"/>
    <action text="查看签到单"  code="signSheet"/>
    <action text="签到二维码"  code="exportQRcode"/>
    <action text="未确认详情"  code="unconfirmed"/>

</section>
<!--Template配置 key是唯一标识，请不要修改已保证页面正常运行-->
<section type="template" id="template">
<a-row>
    <a-col>
        <a-title key="2031551683664047" data-name="会议通知流程"></a-title>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-create-by key="creater" data-name="创建人"></a-create-by>
    </a-col>
    <a-col>
        <a-created-time key="createdTime" data-name="创建时间"></a-created-time>
    </a-col>
    <a-col>
        <a-sequence-no key="sequenceNo" data-name="单据号"></a-sequence-no>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-group-title key="2001551683664048" data-name="会议通知"></a-group-title>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-text key="subject" data-name="标题" data-default-value="会议通知单"></a-text>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-date key="mettingTime" data-name="会议开始时间" data-format="YYYY-MM-DD HH:mm"></a-date>
    </a-col>
    <a-col>
        <a-date key="meetingEndtime" data-name="会议结束时间" data-format="YYYY-MM-DD HH:mm"></a-date>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-user-selector key="signer" data-name="签发人" data-mappings="departments:{signDepartment};"></a-user-selector>
    </a-col>
    <a-col>
        <a-user-selector key="signDepartment" data-name="签发部门" data-dept-visible="org"></a-user-selector>
    </a-col>    <a-col>
        <a-date key="signTime" data-name="签发时间"></a-date>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-association-form key="meetingAddress" data-name="会议地点" data-schema-code="MEETING_ROOM" data-select-mode="dropdown"></a-association-form>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-textarea key="meetingContent" data-name="会议内容" data-max-length="200"></a-textarea>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-attachment key="meetingFile" data-name="会议文件"></a-attachment>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-logic key="hasUserList" data-name="指定参会名单"></a-logic>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-association-form key="meetingClerk" data-name="会议拟办员" data-display-formula="{hasUserList} == false" data-query-code="department_planning_clerk" data-schema-code="department_planning_clerk" data-mappings="department_planning_clerk:{meetingClerkDetail}" data-select-mode="dropdown"></a-association-form>
    </a-col>
    <a-col>
        <a-user-selector key="meetingClerkDetail" data-name="拟办员明细" data-on-change='if(value==""){
    this.meetingClerkState.value = 1;
}else{
    this.meetingClerkState.value = -1;
}' data-display-formula="{hasUserList} == false" data-multi="true"></a-user-selector>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-association-form key="meetingDepartment" data-name="部门组" data-display-formula="{hasUserList} == true" data-query-code="department_group" data-schema-code="department_group" data-mappings="department_lists:{meetingDepartmentRef}" data-select-mode="dropdown"></a-association-form>
    </a-col>
    <a-col>
        <a-user-selector key="meetingDepartmentRef" data-name="部门明细" data-display-formula="{hasUserList} == true||{meetingClerkState} > 0" data-multi="true" data-dept-visible="org"></a-user-selector>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-association-form key="meetingParticipant" data-name="人员组" data-display-formula="{hasUserList} == true" data-query-code="commonly_used_user_group" data-schema-code="commonly_used_user_group" data-mappings="user_group_member:{meetingParticipantDetail}" data-select-mode="dropdown"></a-association-form>
    </a-col>
    <a-col>
        <a-user-selector key="meetingParticipantDetail" data-name="人员组明细" data-display-formula="{hasUserList} == true||{meetingClerkState} > 0" data-multi="true"></a-user-selector>
    </a-col>
</a-row>
<a-row>
    <a-col>
        <a-comment key="ApprovalOpinion1552534404694" data-name="审批意见"></a-comment>
    </a-col>
</a-row>
<div id="test"><img id="testpic"></img></div>
</section>
<!--自定义事件配置-->
<script id="customScript">
    (function(form){
        /**
         * 用户自定义JS区域
         */
        /**
         * 事件绑定，form.on
         * @param eventType 事件类型
         * @params function 事件
         * @param  cover    true, false 是否覆盖root的生命周期 默认不覆盖 
         */
        //数据加载后，渲染之前
        form.on('onLoad',function(data){
        },'cover');

        
      form.on('onRendered',function(data) {
        if(env.isMobile){
            this.actions.forEach(function(res) {
                if(res.code === 'printcustom' || res.code === 'print' || res.code === 'exportQRcode') {
                    res.visible = false;
                }
            });
        }
        
          if (data.sequenceStatus === 'COMPLETED') {
              return;
          }
          var showBtns = ['unconfirmed', 'signSheet', 'exportQRcode', 'print', 'printcustom'];
          this.actions.forEach(function(res) {
             if(showBtns.indexOf(res.code) > -1) {
                 res.visible = false;
             }

          });
       
      })
        //内置校验完成后，返回false阻止提交
        form.on('onValidate',function(action,data){});
       
        //操作前执行，返回false阻止按钮操作
        form.on('onPreAction',function(action,data){
            

            // 打印详情 可以定ding 通知
            if(action.code === 'unconfirmed') {
                // 'http://120.79.187.180/form/detail?sheetCode=MEETING_ROOM&objectId=d77dba18baf94e779191fcfa757dd770&schemaCode=MEETING_ROOM'
                // var url = 'http://120.79.187.180/form/detail?sheetCode=unconfirmed_msg&schemaCode=meeting_notice&objectId='+data.id;
                // this.$router.
                // this.$router.push({ // 业务表单
                //     name: 'form-detail',
                //     query: {
                //     schemaCode: 'meeting_notice',
                //     sheetCode: 'unconfirmed_msg',
                //     objectId: data.id
                //     }
                // });

                var url = '/form/detail?sheetCode=unconfirmed_msg&objectId='+ data.id +'&schemaCode=meeting_notice';
                if(env.isMobile){
                    // window.open('/mobile' + url);
                    this.$router.push(url).catch((err: any) => {err});
                }else{
                    window.parent.location.href = env.redirectHost + url;
                }
                
            }

            if (action.code === 'submit' || action.code === 'save') {
                var _this = this;
                const params = {
                    schemaCode: 'meeting_notice',
                    meetingId: data.meetingAddress.id,
                    mettingTime: data.mettingTime,
                    meetingEndtime: data.meetingEndtime
                }
                return axios.post("/api/meeting/check", params).then(function(res) {
                    if (res.errcode === 0) {
                    } else if (res.errcode === 800001) {
                        var obj = JSON.parse(res.data);
                        var str = '会议室被占用: '+ obj.mettingTime + '至' + obj.meetingEndtime
                        _this.$message.error(str);
                        return false;
                    } else if (res.errcode === 800002) {
                        _this.$message.error('会议开始时间不能晚于会议结束时间!');
                        return false;
                    } else if(res.errcode === 800003) {
                        _this.$message.error('会议开始时间不能早于当前时间!');
                        return false;
                    }
                     else {
                        _this.$message.error(res.errmsg);
                        return false;
                    }
                });
            }

            // 查看签到单
            if(action.code === 'signSheet') {
                // this.$router.push({ // 业务表单
                //     name: 'form-detail',
                //     query: {
                //     schemaCode: 'meeting_notice',
                //     sheetCode: 'sign_sheet',
                //     objectId: data.id
                //     }
                // });

                var url = '/form/detail?sheetCode=sign_sheet&objectId='+ data.id +'&schemaCode=meeting_notice';
                if(env.isMobile){
                    // window.open('/mobile' + url);
                    this.$router.push(url).catch((err) => {err});
                }else{
                    window.parent.location.href = env.redirectHost + url;
                }
            }

            if (action.code === 'printcustom') {
                // this.$router.push({ // 业务表单
                //     name: 'form-detail',
                //     query: {
                //     schemaCode: 'meeting_notice',
                //     sheetCode: 'custom_print',
                //     objectId: data.id
                //     }
                // });
                var url = '/form/detail?sheetCode=custom_print&objectId='+ data.id +'&schemaCode=meeting_notice';
                if(env.isMobile){
                    // window.open('/mobile' + url);
                    this.$router.push(url).catch((err) => {err});
                }else{
                    window.parent.location.href = env.redirectHost + url;
                    // window.open(env.redirectHost + url);
                }
                return false;
            }


            if(action.code=="exportQRcode"){
                var url = '/form/detail?sheetCode=signin_qrcode&objectId='+ data.id +'&schemaCode=meeting_notice';
                if(env.isMobile){
                    // window.open('/mobile' + url);
                    this.$router.push(url).catch((err) => {err});
                }else{
                    window.open(env.redirectHost + url);
                }
            }else if(action.code=="searchQRcode"){
             window.open(window.location.host + "/application/MeetingSystem/application-list/meeting_signin_sheet");
            }
        });
        //操作后执行
        form.on('onActionDone',function(action,data){});
    })
</script>
<script src="/admin/js/chunk-vendors.js" class="templateScript"></script>
<script src="/admin/js/template.js" class="templateScript"></script>
</body>
</html>